home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d18
/
djvga02.arc
/
DJVGA.DOC
< prev
next >
Wrap
Text File
|
1991-05-17
|
24KB
|
633 lines
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-
DJVGA Version .02 Beta
(C) Copyright 1991 John Richardson
By: John Richardson & Dan Vanderboom
TopSoft Support Systems
Fido [1:154/300,1:154/301]
RBBS-NET [8:972/1001,8:972/1000]
(414)796-8408 v32
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-
Registration
============
DJVGA is distributed as shareware. Please read and return the
registration form in REGISTER.FRM. If you are already a registered
user (ie. you sent in $10 for some version previous to 1.00), then
you are entitled to a registered version of DJVGA 1.00 without
paying any additional fee. You may also register online at TopSoft
Support Systems using your Visa/MC.
NOTE: UPON REGISTERING YOU "WILL" RECEIVE THE ASM AND PASCAL SOURCE CODE
Warranty
========
This is product is provided "as is" without warranty of any kind. The
entire risk as to the results and performance of the program is assumed by
you. Further more, I the author do not warrant, guarantee, or make any
representations regarding the use of, or the results of the use of the program,
and you rely on the program and results solely at your own risk. I the author
cannot accept responsibility for system damage, loss of profit, or any other
special, incidental, or consequential damages resulting from the use or
inability to use this product.
Copyright
=========
The DJVGA library is distributed as SHAREWARE. Under this concept
you may use the SHAREWARE (unregistered) version for a reasonable period of
time, which I consider to be two weeks, after which you must either register
your copy or discontinue usage.
Distribution
============
You are free, in fact encouraged, to distribute the SHAREWARE (unregistered)
version of DJVGA library provided that all files contained in the
original DJVGA archive are distributed in their original unmodified state.
What is DJVGA?
==============
DJVGA is a toolkit of low-level programmed graphic routines for the EGA/VGA
Turbo Pascal v6.0 programmers that can be used to completely replace or
to be used with Borland's BGI interface.
The common programmer who wants optimized and fast code will find this unit
to be very helpful in developing their applications. It will only add
a small 3k (maybe more) to your final .EXE program if you use all of the
procedures and functions. DJVGA will run up to 1000% faster than the
BGI interface, so choose wisely!
DJVGA - Procedures and Functions
================================
Summary of Procedures and Functions (described in detail below):
Function DJ_GetVideo:AdapterType;
Procedure DJ_ClrScr;
Procedure DJ_VGASetPalette(Pale:VGAPaletteType);
Procedure DJ_SetPage(Page:Integer);
Function DJ_GetPage:Integer;
Procedure DJ_DPutPixel(Row,Column,Color:Integer);
Function DJ_DGetPixel(Row,Column:Integer):Integer;
Procedure DJ_SetVideoMode(Number:Byte);
Function DJ_GetVideoMode:Integer;
Function DJ_TextHeight:Word;
Procedure DJ_Line(X1,Y1,X2,Y2,Color:Integer);
Procedure DJ_GetImage(X1,Y1,X2,Y2:Integer; Image:Pointer);
Procedure DJ_PutImage(X1,Y1:Integer; Image:Pointer);
Procedure DJ_SetMode(Mode:Integer);
Procedure DJ_Ellipse(X,Y,XRadius,YRadius,Color:Integer);
Procedure DJ_SwitchBank(Bank:Integer);
Procedure DJ_Lines_From_Center(Color,Size:Integer);
Procedure DJ_Fade(NumPix:LongInt; Color:Integer);
Procedure DJ_Filled_Rectangle(StartCol,StartRow,EndCol,EndRow,Color:Integer);
=============================================================================
Syntax : Function DJ_GetVideo:AdapterType;
Function : Returns the current video hardware that the system has.
Description: DJ_GetVideo searches your computer and determines what type
of video hardware you have hooked up to the system.
DJ_GetVideo will return one of the following in the
enumerated type of AdapterType:
AdapterType = (None,MDA,CGA,Hercules,EGA,MCGA,VGA);
Example : Program SeeAdapter;
..
..
Begin
Case DJ_GetVideo Of
None:WriteLn('No video adapter found!');
MDA:WriteLn('MDA found!');
CGA:WriteLn('CGA found!');
Hercules:WriteLn('Hercules found!');
EGA:WriteLn('EGA found!');
MCGA:WriteLn('MCGA found!');
VGA:WriteLn('VGA found!');
End;
End.
=============================================================================
Syntax : Procedure DJ_ClrScr;
Function : Clears the video screen at $A000.
Description: DJ_ClrScr will clear the screen in most EGA/VGA video modes
such as 320x200x16. It works much like the CRT procedure
ClrScr;
Example : Program ClearScreenNeatoEh;
..
..
Begin
DJ_SetVideoMode($0D); { EGA 320x200x16 }
For I1 := 1 To 100 Do
For I2 := 1 To 100 Do
DJ_DPutPixel(I1,I2,Random(14)+1));
ASM
MOV AH,1 { Function: Wait For A Key }
INT 21H { Call DOS }
End;
DJ_ClrScr;
ASM { The screen cleared eh? }
MOV AH,1
INT 21H
End;
DJ_SetVideoMode($03); { Regular Text Mode }
End.
=============================================================================
Syntax : Procedure DJ_VGASetPalette(Pale:VGAPaletteType);
Function : Sets the palette on the VGA.
Description: DJ_VGASetPalette will change the colors of the current
VGA Palette. You can choose 256 out of something around
65,500.
Example : Program MakeColorsForBlind;
..
..
Begin
For I := 0 To 255 Do Pl[I] := 0;
DJ_VGASetPalette(Pl);
End;
{ now see if you can see any of the VGA colors :-) }
=============================================================================
Syntax : Procedure DJ_SetPage(Page:Integer);
Function : Select your video page.
Description: DJ_SetPage will select the video page you want to use on
the EGA/VGA.
Pages 0-7 can be used in 320x200x16
Pages 0-3 can be used in 640x200x16
Pages 0-1 can be used in 640x350x16
This procedure can be helpful for when doing animation
sequences. Switching between video pages quickly to
produce a smooth effect.
Example : Program SetMyPageAndGetItToo;
..
..
Begin
DJ_SetVideoMode($0D); { EGA 320x200x16 }
DJ_Line(10,10,100,100);
DJ_SetPage(1); { Set video page 1}
{ where did the line go }
WriteLn(DJ_GetPage); { it should say 1 }
ASM
MOV AH,1 { DOS: Get key function }
INT 21H { Call DOS }
End;
DJ_SetPage(0); { Set back to 0 }
{ There's the line }
DJ_SetVideoMode($03); { Regular Text Mode }
End.
=============================================================================
Syntax : Function DJ_GetPage:Integer;
Function : Returns the current video page.
Description: DJ_GetPage will return the current video page. If you
previously used DJ_SetPage(1) it will return 1. This is
used to tell what video page you are on, in case you are
in some superb animation flick or something to that effect.
Example : See DJ_SetPage.
=============================================================================
Syntax : Procedure DJ_DPutPixel(Row,Column,Color:Integer);
Function : Puts a pixel directly on screen.
Description: DJ_DPutPixel puts a pixel (a tiny dot) on the screen using
ports for quick direct access. It is much faster than calling
an interrupt. The parameters are self explanitory.
Example : Program PixTest;
..
..
Var R1,R2,I,I1,I2:Integer;
Function KeyPressed:Boolean; Assembler;
ASM
MOV AH,0BH { check if key has been pressed? }
INT 21H { call dos }
AND AL,AL { if a key pending ? }
JZ @no { nope }
MOV AL,True { yupe }
@no:
End;
Begin
DJ_SetVideoMode($0D); { 320x200x16 EGA }
Repeat
R1 := Random(14)+1;
R2 := Random(14)+1;
For I1 := 1 To 200 Do
Begin
For I2 := 1 To 200 Do
Begin
DJ_DPutPixel(I1,I2,R1);
DJ_DPutPixel(I2,I1,R2);
End;
End;
Until KeyPressed;
{ clear the keypress }
ASM
MOV AH,1 { keyport input }
INT 21H { call DOS }
End;
{ return to text mode }
DJ_SetVideoMode($03);
End.
=============================================================================
Syntax : Function DJ_DGetPixel(Row,Column:Integer):Integer;
Function : Returns the color of the pixel addressed.
Description: DJ_DGetPixel returns the current color of the pixel given.
If you previously put a pixel on the screen using DJ_DPutPixel
you can use DJ_DGetPixel and get the color of it. This function
can be used to produce some special effects along with
DJ_DPutPixel.
Example : Program GetPixTesterHereWeGo;
..
..
Var R1,R2,I,I1,I2:Integer;
Function KeyPressed:Boolean; Assembler;
ASM
MOV AH,0BH { check if key has been pressed? }
INT 21H { call dos }
AND AL,AL { if a key pending ? }
JZ @no { nope }
MOV AL,True { yupe }
@no:
End;
Begin
DJ_SetVideoMode($0D); { 320x200x16 EGA }
For I := 1 To 100 Do DJ_DPutPixel(Random(319)+1,Random(199)+1,Random(14)+1);
For I1 := 1 To 320 Do
Begin
For I2 := 1 To 200 Do
Begin
If KeyPressed Then
Begin
ASM
MOV AH,1 { clear keypress }
INT 21H
MOV AX,0003H { set video mode back to text }
INT 10H
End;
Halt(0);
End;
If DJ_DGetPixel(I1,I2) > 0 Then DJ_DPutPixel(I1,I2,0); { change to black }
End;
End;
ASM
MOV AH,1 { keyport input }
INT 21H { call DOS }
End;
{ return to text mode }
DJ_SetVideoMode($03);
End.
=============================================================================
Syntax : Procedure DJ_SetVideoMode(Number:Byte);
Function : Set the video mode
Description: DJ_SetVideoMode is used to set the video mode. You can
set it to any mode using the procedure but not all of them
will work with the other functions in this unit. The most
reliable video modes to use for this unit are:
320x200x16 EGA/VGA $0D
640x200x16 EGA/VGA $0E
640x350x16 EGA/VGA $10
and there are many others that can be used such as the
256 color VGA modes.
Example : Program TestSettingTheVideoMode;
..
..
Begin
DJ_SetVideoMode($0D); { 320x200x16 EGA/VGA }
WriteLn(DJ_GetVideoMode);
WriteLn('Hello John Doe!');
ASM
MOV AH,1
INT 21H
End;
DJ_SetVideoMode($03); { Text mode }
End.
=============================================================================
Syntax : Function DJ_GetVideoMode:Integer;
Function : Returns the current video mode in used.
Description: DJ_GetVideoMode returns the current video mode in use.
Example : See DJ_SetVideoMode.
=============================================================================
Syntax : Function DJ_TextHeight:Word;
Function : Returns the textheight of the current font used.
Description: DJ_TextHeight works much like the TextHeight procedure in
the GRAPH unit but does not require a parameter because it
is font sensitive. It will usually return a height of 8
if in text mode.
Example : Program IThinkWeNeedTheTextHeight;
..
..
Begin
WriteLn(DJ_TextHeight); { Simple eh? }
End.
=============================================================================
Syntax : Procedure DJ_Line(X1,Y1,X2,Y2,Color:Integer);
Function : Draw a line from anywhere to anywhere on the screen.
Description: DJ_Line will draw a line on the screen from X1,Y1 to X2,Y1
in the Color specified. It uses very fast direct port and
screen access to draw the line which gives it its fast speed
and small size.
Example : Program LetsDrawABoxInRed;
..
..
Begin
DJ_SetVideoMode($0D); { 320x200x16 EGA/VGA }
{ draw box around screen }
DJ_Line(10,10,300,10,12);
DJ_Line(300,10,300,180,12);
DJ_Line(300,180,10,180,12);
DJ_Line(10,180,10,10,12);
{ aren't you getting SICK of these ASM statements :-) }
ASM
MOV AH,1 { wait for a key func }
INT 21H { call DOS }
End;
{ go back to text mode }
DJ_SetVideoMode($03);
End.
=============================================================================
Syntax : Procedure DJ_GetImage(X1,Y1,X2,Y2:Integer; Image:Pointer);
Function : Saves a bitmap image of the specified region into memory.
Description: DJ_GetImage copies an image from the screen to memory.
X1,Y1,X2, and Y2 define the area of the screen to which the
square is to be copied. Image points to the area in memory
where the bitmap image is stored. The first two integers
of this area are used for the width and the height of the
rectangle; the remainder holds the image itself.
Example : Program TestGetImage;
..
..
Var BitImage:Pointer;
Begin
DJ_SetVideoMode($0D); { EGA 320x200x16 }
DJ_GetImage(1,1,50,50,BitImage); { save image }
DJ_ClrScr; { clear screen }
DJ_PutImage(1,1,BitImage); { restore image }
DJ_SetVideoMode($03); { Regular Text Mode }
End.
=============================================================================
Syntax : Procedure DJ_PutImage(X1,Y1:Integer; Image:Pointer);
Function : Writes a bitmap image of the specified region onto the screen.
Description: DJ_PutImage copies an image from memory to screen.
X1,Y1 are the corner coordinates at which you want to display
the saved image.
Example : See DJ_GetImage.
=============================================================================
Syntax : Procedure DJ_SetMode(Mode:Integer);
Function : Change the current drawing function.
Description: DJ_SetMode changes the current writing mode to the screen. It
is set as a default to DJReplace. This routine can be used in
conjunction with DJ_Line/DJ_PutImage/DJ_DPutPixel, etc to make
some impressing animation/special effects.
Here are the following parameters that can be used with
this routine:
DJReplace = $00;
DJAND = $08; { AND the image to the screen }
DJOR = $10; { OR the image to the screen }
DJXOR = $18; { XOR the image to the screen }
Example : Program IGiveUpAtThisProgrammingJob_Not;
..
..
Begin
DJ_SetVideoMode($0D); { 320x200x16 EGA/VGA }
DJ_SetMode(DJXOR);
DJ_Line(10,10,50,50); { Now you see it }
ASM
MOV AH,1
INT 21H
End;
DJ_Line(10,10,50,50); { Now you don't :-) }
DJ_SetVideoMode($03); { Text mode (AGAIN!!!) }
End.
=============================================================================
Syntax : Procedure DJ_Ellipse(X,Y,XRadius,YRadius,Color:Integer);
Function : Draw an ellipse/circle on the screen.
Description: DJ_Ellipse is a superfast and supercharged ellipse/circle
drawing routine. You must have a little knowledge of what
a radius is before using this routine. The rest of it
is self-explanitory.
Example : Program Circle_Around_And_Around_And_Around_And;
..
..
Begin
DJ_SetVideoMode($0D); { EGA/VGA 320x200x16 }
DJ_Ellipse(110,100,60,50,15); { Draw a NEAT design }
DJ_Ellipse(120,100,65,55,12); { on the screen }
DJ_Ellipse(130,100,70,60,11);
DJ_Ellipse(140,100,75,65,10);
DJ_Ellipse(115,100,80,70,9);
DJ_Ellipse(125,100,85,75,8);
DJ_Ellipse(135,100,90,80,7);
DJ_Ellipse(140,100,95,85,13);
DJ_Ellipse(145,100,100,90,14);
ASM
MOV AH,1
INT 21H
End;
DJ_SetVideoMode($03); { Text mode }
End.
=============================================================================
Syntax : Procedure DJ_SwitchBank(Bank:Integer);
Function : Switch to the alternate bank of memory on SuperVGA cards.
Description: DJ_SwitchBank will switch to different memory banks on
many SuperVGA cards. To call this routine you will need
to know which kind of SuperVGA card it is (refer to
DJ_SuperVGA procedure, if you do not know). This routine
supports the following cards:
TSeng3 = 1; { Tseng 3000 }
TSeng4 = 2; { Tseng 4000 }
Wonder = 3; { VGA Wonder }
Paradise = 4; { Pardise VGA }
Vid7 = 5; { Video 7 VGA }
Example : Program LetsTryItAllOverAgain;
..
..
Begin
DJ_SetVideoMode($13); { 320x200x256 VGA }
SwitchBank(Vid7); { Switch to alternate bank }
DJ_SetVideoMode($03); { Text mode (AGAIN!!!) }
End.
=============================================================================
Syntax : Procedure DJ_Lines_From_Center(Color,Size:Integer);
Function : Draw a bunch of lines coming from the centermost part of
the screen.
Descripton : DJ_Lines_From_Center draws a bunch of lines coming from the
centermost part of the screen. The size of the lines can
be set by the Size parameter. This routine was written
mainly for testing purposes.
Example : Program NeatoBobFredTimJedAndJohn;
..
..
Begin
DJ_SetVideoMode($0D); { EGA/VGA 320x200x16 }
Repeat
DJ_Lines_From_Center(11,Random(150)+1);
DJ_ClrScr;
Until KeyPressed;
ASM
MOV AH,1
INT 21H
End;
DJ_SetVideoMode($03); { Text Mode (AGAIN!!!) }
End.
=============================================================================
Syntax : Procedure DJ_Fade(NumPix:LongInt; Color:Integer);
Function : Produces a fading effect into any color in the palette.
Description: DJ_Fade will fade your screen all the way, partially, or just
a little bit by specifying how many pixel blocks to fade in the
NumPix parameter. DJ_Fade can fade the screen into any color,
but the most used is usually black to procedure a screen clearing
special effect.
Example : Program Neato_Boom_Wow_Hi;
..
..
Begin
DJ_SetVideoMode($0D); { 320x200x16 EGA/VGA }
DJ_Fade(MaxPixs,12);
ASM
MOV AH,1
INT 21H
End;
DJ_Fade(MaxPixs,0);
ASM
MOV AH,1
INT 21H
End;
DJ_SetVideoMode($03); { Text mode (AGAIN!!!) }
End.
=============================================================================
Syntax : Procedure DJ_Filled_Rectangle(StartCol,StartRow,EndCol,EndRow,
Color:Integer);
Function : Draw a filled rectangle.
Description: DJ_Filled_Rectangle fills a specified part of the screen with
a color of your choice in the shape of a square or a rectangle.
This procedure is used in our demo program to clear the screen
in a fancy manor.
Example : Program ImGettingTiredOfTheseDumbNames;
..
..
Begin
DJ_SetVideoMode($0D); { 320x200x16 EGA/VGA }
{ This will be simple demo! }
Repeat
DJ_Filled_Rectangle(0,0,320,200,Random(15)+1);
Until KeyPressed;
ASM
MOV AH,1
INT 21H
End;
DJ_SetVideoMode($03); { Text mode (AGAIN!!!) }
End.
=============================================================================
To keep the lawyers happy:
BGI (Borland Graphical Interface) and Turbo Pascal are registered trademarks
of Borland International.
Epilog
======
Please enjoy the program and feel free to contact TopSoft Support Systems,
with any comments or questions concering this product.
Thanks,
John Richardson
TopSoft Support Systems
(414) 796-8408
12/24/96/19.2/38.4 - V32/V42
PC-Pursuitable D/WIMIL/24
Fido [1:154/300,1:154/301]
RBBS-Net [8:972/1001,8:972/1000]